package com.alibaba.aone.casestudy.dao.impl;

import java.util.List;

import com.alibaba.aone.casestudy.common.entity.Failure;
import com.alibaba.aone.casestudy.common.entity.FailureConditions;
import com.alibaba.aone.casestudy.dao.FailureDao;
import com.alibaba.intl.commons.framework.ibatis.BaseSqlMapClientDaoSupport;

/**
 * 类IbatisFailtureDao.java的实现描述：TODO 类实现描述
 * 
 * @author yongchun.chengyc 2011-4-27 上午10:36:49
 */
public class IbatisFailureDao extends BaseSqlMapClientDaoSupport implements
		FailureDao {

	public Failure getFailureByNumber(String number) {

		return (Failure) getSqlMapClientTemplate().queryForObject(
				"FAILURE.getFailureByNumber", number);
	}

	public List<Failure> selectFailure(FailureConditions failureConditions) {

		return getSqlMapClientTemplate().queryForPagination(
				"FAILURE.countFailure", "FAILURE.selectFailure",
				failureConditions);
	}

	public void update(Failure failure) {
		getSqlMapClientTemplate().update("FAILURE.updateFailure", failure);

	}

	public void add(Failure failure) {
		getSqlMapClientTemplate().insert("FAILURE.addFailure", failure);
	}

	public List<Failure> getAllFailures() {

		/*return getSqlMapClientTemplate().queryForPagination(
				"FAILURE.countFailure", "FAILURE.selectFailure", null);
	}*/
		return getSqlMapClientTemplate().queryForList("FAILURE.getAllFailures");
	}

	public Integer setFailureNumber() {
		
		return (Integer) getSqlMapClientTemplate().queryForObject("FAILURE.lastId");
	}

	public void delete(String number) {
		getSqlMapClientTemplate().delete("FAILURE.deleteFailure");
		
	}

}
